package com.mlf.abstractFactory;

import com.mlf.abstractFactory.demo.peripheral.Keyboard;
import com.mlf.abstractFactory.demo.peripheral.Mouse;
import com.mlf.abstractFactory.demo.peripheral.OfficePeripheralFactory;
import com.mlf.abstractFactory.demo.peripheral.PeripheralFactory;
import com.mlf.abstractFactory.demo.ui.GUIFactory;
import com.mlf.abstractFactory.demo.ui.MacFactory;
import com.mlf.abstractFactory.demo.ui.WinFactory;

public class AbstractFactoryDemo {
    public static void main(String[] args) {
        //生产一套游戏外设
//        PeripheralFactory factory = new GamingPeripheralFactory();
        //生产一套办公设备
        PeripheralFactory factory = new OfficePeripheralFactory();
        Keyboard keyboard = factory.createKeyboard();
        Mouse mouse = factory.createMouse();
        System.out.println("==========================");
        System.out.println("键盘类型: " + keyboard.getDescription());
        System.out.println("鼠标类型: " + mouse.getDescription());
        System.out.println("==========================");
        guiDemo();
    }


    public static void guiDemo() {
        GUIFactory factory;

        // 根据配置选择工厂
        String type = "Windows";
        if ("Windows".equals(type)) {
            factory = new WinFactory();
        } else {
            factory = new MacFactory();
        }
        Button button = factory.creatButton();
        Checkbox checkbox = factory.creatCheckbox();
        button.render();
        checkbox.check();
    }
}
